package com.zm.tools.util.core;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 类说明:身份证信息提取
 * @author zoum
 * @date 2018/6/6 18:34.
 */
public class IdcardUtil {

    public static String getGender(String idCard){
        char gerderCode = idCard.charAt(16);
        if (Integer.valueOf(gerderCode)%2 != 0){
            return "male";
        }else {
            return "femal";
        }
    }

    public static int getAge(String idCard){
        String ageCode = idCard.substring(6,14);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        String now = sdf.format(new Date());;
        return (Integer.valueOf(now) - Integer.valueOf(ageCode)) / 10000;
    }
}